In the realm of computer science, garbage collection (GC) is a form of automatic memory management in which a garbage collector finds and reclaims memory occupied by data that is no longer in use by an executing program. Garbage collection can consume a significant proportion of processing resources and thus can have a significant impact on performance. The advantages of garbage collection include but are not limited to the following. The programmer does not have to explicitly de-allocate memory, thereby eliminating or substantially reducing the types of programming bugs associated with these activities.
In addition, with GC, certain types of memory leaks can be avoided. A memory leak occurs when the memory occupied by unreachable objects becomes unusable. However, because the garbage collector determines which memory to free, overhead is incurred, which can lead to decreased or uneven performance Additional memory is often needed to compensate for the GC overhead in order for the program to be able to perform as fast as when explicit memory management is performed. Pauses in program execution may occur at the time at which the garbage is actually collected. These pauses may be unacceptable when performing certain tasks.